/*!
 * OpenSocial jQuery Mini Message 1.0.0
 * http://code.google.com/p/opensocial-jquery/
 *
 * Copyright(C) 2009 Nakajiman Software Inc.
 * http://nakajiman.lrlab.to/
 *
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 */
jQuery.fn.extend({

  minimessage: function(speed, fn) {

	if (jQuery.isFunction(speed)) {
      fn = speed; speed = null;
    }

    var speeds = { slow: 5, normal: 3, fast: 1 };

    if (speed && typeof speed !== 'number')
	  speed = parseInt(speed, 10) || speeds[speed] || speeds.normal;

	return this.pushStack(jQuery.map(this, function(self) {
      
	  if (self.parentNode)
        self.parentNode.removeChild(self);
	  
	  var message = speed
	    
		? new gadgets.MiniMessage()
		  .createTimerMessage(self, speed, function() {
	        return (fn || function() {}).apply(message) !== false;
	      })
	    
		: new gadgets.MiniMessage()
		  .createDismissibleMessage(self, function() {
	        return (fn || function() {}).apply(message) !== false;
          });
	  
	  return message;
    
	}));
  
  }
});
